package data;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;

import domain.Comentario;
import domain.Manifestacion;

public class JDBCManifestacionDAO {
	
	IComentarioDAO cdao;
    
    public JDBCManifestacionDAO() {
        cdao = new JDBCComentarioDAO();
    }
	
	
	public List listarComentarios(Connection conn,String manifestacionOID){
		
		List comentarios = new LinkedList();
        String sql = "SELECT * FROM Manifestacion WHERE (manifestacionOID = ? ) ";
        PreparedStatement stmt = null;
       // ResultSet result = null;

        try {
            stmt = conn.prepareStatement(sql);
            stmt.setString(1, manifestacionOID);

            //result = stmt.executeQuery();

           // while (result.next()) {
                Manifestacion m =  new Manifestacion();
              //  Comentario c = cdao.select(conn, result.getString("comentarioOID"));
                comentarios.add(m.getListaComentarios());
            //}
        } catch (SQLException e) {
            System.out.println("Message: " + e.getMessage());
            System.out.println("SQLState: " + e.getSQLState());
            System.out.println("ErrorCode: " + e.getErrorCode());
        } finally {
            try {
//                if (result != null) {
//                    result.close();
//                }

                if (stmt != null) {
                    stmt.close();
                }
            } catch (SQLException e) {
            }
        }

        return comentarios;
    }
}
